﻿//********************************************************************************//
//创建日期：<创建日期，2016-04-27>
//创建作者：<朱大鹏，zhudapeng@shanghai3h.com>
//modify:guodengjie
//功能说明：月度调整登记
//********************************************************************************//
using System;
using Entity;
using BLL;
using BLL.Access;
using System.Data;

namespace Web.Pages.YongShui._13.LAIHANGL
{
    public partial class YUEDUTZDJ : BasePage
    {
        #region 属性
        //public string LaiHanID
        //{
        //    get { return hdCollection.Contains("LaiHanID") ? hdCollection.Get("LaiHanID").ToString() : ""; }
        //    set { hdCollection.Set("LaiHanID",value); }
        //}
        //public string LaiHanLCBH
        //{
        //    get { return hdCollection.Contains("LaiHanLCBH") ? hdCollection.Get("LaiHanLCBH").ToString() : ""; }
        //    set { hdCollection.Set("LaiHanLCBH", value); }
        //}

        //private string laihanbh
        //{
        //    get
        //    {
        //        return Convert.ToString(ViewState["laihanbh"]);
        //    }
        //    set
        //    {
        //        ViewState["laihanbh"] = value;
        //    }
        //}
        #endregion

        #region 变量
        /// <summary>
        /// 访问数据库
        /// </summary>
        SpHelper _sphelper = new SpHelper();
        /// <summary>
        /// 来函信息
        /// </summary>
        YS_LH_LAIHANXXProcess bllh = new YS_LH_LAIHANXXProcess();
        /// <summary>
        /// 月调整
        /// </summary>
        YS_LH_YUETIAOZProcess bllyue = new YS_LH_YUETIAOZProcess();
        /// <summary>
        /// 上传
        /// </summary>
        SYS_UPLOADProcess bllupload = new SYS_UPLOADProcess();
        /// <summary>
        /// 用户信息
        /// </summary>
        YS_YG_YONGHUXXProcess bllyhxx = new YS_YG_YONGHUXXProcess();
        /// <summary>
        /// 流程
        /// </summary>
        YS_LH_LAIHANLCJLBLL lcbll = new YS_LH_LAIHANLCJLBLL();
        /// <summary>
        /// 日志
        /// </summary>
        SYS_LOGBLL _SYS_LOGBLL = new SYS_LOGBLL();
        /// <summary>
        /// 来函保存用户信息
        /// </summary>
        YS_LH_YONGHUXXProcess laihanyhxx = new YS_LH_YONGHUXXProcess();
        #endregion

        #region 事件
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }            
        }

        protected override void OnLoadComplete(EventArgs e)
        {
            //对需要加载页上的所有其他控件的任务使用该事件。
            if (!IsPostBack)
            {
                BindEditData();               
            }

        }
        //protected void btnActPerform_Click(object sender, EventArgs e)
        //{
        //    UCLHCaiLiaoInfo.BindCheckBox(UCLHUserInfo.YONGHUH, h_laihan.Value);
        //}
        protected void ASPxCallbackCommon_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            //if (e.Parameter == "sj")
            //{
            //    e.Result = e.Parameter+"|"+AddLAIHANXX(0); 
            //}
            //else if (e.Parameter == "dj")
            //{
            //    e.Result = e.Parameter + "|" + AddLAIHANXX(1); 
            //}
            //else if (e.Parameter == "zlsc")
            //{
                
            //    e.Result = e.Parameter + "|" + UCLHBtnBottom.SelectIndex.ToString() + "|0";
            //}
            //else if (e.Parameter == "jh")
            //{
            //    e.Result = e.Parameter + "|" + BindYJH();
            //}
            //else if (e.Parameter == "checkbox")
            //{
            //    e.Result = e.Parameter + "|" + BindCheckBox()+"|0";
            //}
            //e.Result = "收件"+e.Parameter;
        }
        /// <summary>
        /// 退回
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void BtnBack_Click(object sender, EventArgs e)
        //{

        //    Save(-2);
        //}
        /// <summary>
        /// 受理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void BtnSL_Click(object sender, EventArgs e)
        //{

        //    Save(2);
        //}
        /// <summary>
        /// 不受理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void BtnBSL_Click(object sender, EventArgs e)
        //{
        //    Save(-1);
        //}
       
        #endregion

        #region 方法

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="type">0退回 2受理 -1不受理</param>
        private void Save(int type)
        {     
            /*
            string laihanzbupdatecol = string.Format("I_LIUCHENGBH={0},S_SHENQINGLY='{1}',S_BEIZHU='{2}'", 3,"", "");
            if (type == -1)
            {
                laihanzbupdatecol = string.Format("S_SHENQINGLY='{1}',S_BEIZHU='{2}',I_LIUCHENGZT={0}", type, "", "");

            }
            else if (type == -2)
            {
                laihanzbupdatecol = string.Format("I_LIUCHENGBH={0},S_SHENQINGLY='{1}',S_BEIZHU='{2}'", type, "", "");

            }
            string where = string.Format(" ID={0} ", LaiHanID);
           
            int success = bllh.UpdateYS_LH_LAIHANXXesDynamic(laihanzbupdatecol, where);
            if (success > 0)
            {
                ///添加受理开始信息
                YS_LH_LAIHANLCJL lcjl = new YS_LH_LAIHANLCJL();
                lcjl.D_CAOZUORQ = DateTime.Now;
                lcjl.D_STARTDATE = DateTime.Now;
                lcjl.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
                lcjl.I_LAIHANLX = 1;
                lcjl.I_LIUCHENGBH = type;

                lcjl.ID = 0;

                if (type == -2 || type == -1)
                {
                    lcjl.D_ENDDATE = DateTime.Now;
                }

                DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ", UCLHUserInfo.LAIHANBH, type), "", null);
                if (lcxx != null && lcxx.Rows.Count > 0)
                {
                    lcjl.ID = Convert.ToInt32(lcxx.Rows[0]["ID"]);
                }
                lcjl.S_LAIHANBH = UCLHUserInfo.LAIHANBH;

                lcjl.S_LIUCHENGMC = type == 2 ? "受理" : type == -1 ? "不受理" : "退回";

                lcbll.InsertOrUpdate(lcjl);

                _SYS_LOGBLL.Log<YS_LH_LAIHANLCJL>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "来函月登记受理-" + lcjl.S_LIUCHENGMC + "(" + (Convert.ToInt32(txtJHL.Text) * 100) + ")", OperateState.Modify, lcjl, null);


                ///更新受理结束事件
                lcbll.UpdateYS_LH_LAIHANLCJLsDynamic(string.Format("D_ENDDATE=sysdate,I_CAOZUOR={0},D_CAOZUORQ=sysdate", LoginInfo.CurrentUser.UserID), " I_LIUCHENGBH=2 and D_ENDDATE is null and S_LAIHANBH='" + lcjl.S_LAIHANBH + "'");
                if (type > 0)
                {
                    AddYEWUYUAN();
                    lcbll.UpdateYS_LH_LAIHANLCJLsDynamic(string.Format("D_ENDDATE=sysdate,I_CAOZUOR={0},D_CAOZUORQ=sysdate", LoginInfo.CurrentUser.UserID), " I_LIUCHENGBH=1 and S_LAIHANBH='" + lcjl.S_LAIHANBH + "'");

                }
                //PageTools.AlertMsg(this, "操作完成", "ReloadParent();");

                //System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), DateTime.Now.ToString("yyyyMMddHHmmssfff"), new System.Text.StringBuilder("window.close();").ToString(), true);
                //System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), DateTime.Now.ToString("yyyyMMddHHmmssfff"), new System.Text.StringBuilder("alert('操作完成');parent.layer.closeAll();").ToString(), true);

            }
            */

        }
        private void AddYEWUYUAN()
        {
            ///添加流程记录业务员意见开始信息
            YS_LH_LAIHANLCJL lcjl = new YS_LH_LAIHANLCJL();
            lcjl.D_CAOZUORQ = DateTime.Now;
            lcjl.D_STARTDATE = DateTime.Now;
            lcjl.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
            lcjl.I_LAIHANLX = 1;
            lcjl.I_LIUCHENGBH = 3;
            lcjl.ID = 0;

            DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ", UCLHUserInfo.LAIHANBH, 3), "", null);
            if (lcxx != null && lcxx.Rows.Count > 0)
            {
                lcjl.ID = Convert.ToInt32(lcxx.Rows[0]["ID"]);
            }
            lcjl.S_LAIHANBH = UCLHUserInfo.LAIHANBH;

            lcjl.S_LIUCHENGMC = "业务员意见";

            lcbll.InsertOrUpdate(lcjl);

        }
        /// <summary>
        /// 判断必传文件是否上传
        /// </summary>
        /// <param name="laihanbh"></param>
        /// <returns></returns>
        private bool CheckCAILIAO(string laihanbh)
        {
            string where = "";
            where = string.Format(" S_YONGHUBH='{0}' and  I_WENJIANLX=2 and S_LAIHANBH='{1}' and I_JLZT=0 ", UCLHUserInfo.YONGHUH,laihanbh);
            DataTable dt = bllupload.SelectSYS_UPLOADsDynamic(where,"",null);
            if (dt != null && dt.Rows.Count > 0)
            {
                return true;
            }
            if (Session["gaopai"] != null)
            {
                DataTable cailiao = Session["gaopai"] as DataTable;
                if (cailiao != null && cailiao.Rows.Count > 0)
                {
                    foreach (DataRow dr in cailiao.Rows)
                    {
                        if (dr["value"].ToString() == "2")
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }

        
        /// <summary>
        /// 添加来函信息
        /// </summary>
        //private string AddLAIHANXX(int liuchengzt)
        //{           
               
        //    //if ((!string.IsNullOrEmpty(Request["laihanbh"]) && !string.IsNullOrEmpty(Request["id"])) && (LaiHanID != "" && LaiHanID!="0"))
        //    //{ 
        //    //    LaiHanID=Request["id"];
        //    //}
        //    //if (LaiHanID == "" || LaiHanID == "0")
        //    //{
        //    //    isAdd = true;
        //    //}
        //    //else
        //    //{
        //    //    isAdd = false;
        //    //}
        //    string msg = "";
        //    //if (UCLHUserInfo.YONGHUH.Trim().Length == 0)
        //    //{
               
        //    //    return "请输入用户号并搜索相关信息|-1";
        //    //}
        //    //int y, m;
        //    //string yd = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
        //    //int year = Convert.ToInt32(yd.Substring(0, 4));
        //    //int month = int.Parse(yd.Substring(4, 2));
        //    //if (!int.TryParse(UCLHUserInfo.Y, out y) || !int.TryParse(UCLHUserInfo.M, out m) || m > 12 || m < 1)
        //    //{
              
        //    //    return "年月输入错误|-2";
        //    //}
        //    //if (y * 100 + m < year * 100 + month)
        //    //{
               
        //    //    return "年月必须大于/等于当前水量年月|-3";
        //    //}
        //    //if (txtYJH.Text.Trim().Length == 0)
        //    //{
                
        //    //    return "无用户相关计划信息|-4";
        //    //}
           
        //    //int shenqing = 0;
        //    //if (!int.TryParse(txtJHL.Text, out shenqing))
        //    //{
        //    //    return "申请计划量输入错误|-6";
        //    //}
        //    //添加来函主表
        //    bool isAdd = true;
        //    YS_LH_LAIHANXX laihan=null;
        //    if (LaiHanID != "0" && LaiHanID != "")
        //    {
        //        laihan = this.bllh.SelectYS_LH_LAIHANXX(int.Parse(LaiHanID));
        //        isAdd = false;
        //        laihan.ID = int.Parse(LaiHanID);
        //    }
        //    else
        //    {
        //        laihan = new YS_LH_LAIHANXX();
        //        isAdd = true;
        //        laihan.ID = 0;
        //    }   
        //    laihan.D_SHURURQ = DateTime.Now;
        //    laihan.D_LAIHANRQ = DateTime.Now;
        //    laihan.I_JLZT = 0;
        //    laihan.I_LAIHANLX = 1;
        //    laihan.I_LIUCHENGBH = liuchengzt;
        //    laihan.I_M = Convert.ToInt32(UCLHUserInfo.M);
        //    laihan.I_SHURUR = LoginInfo.CurrentUser.UserID;
        //    laihan.I_Y = Convert.ToInt32(UCLHUserInfo.Y);
        //    if (LaiHanLCTools.HasRelationExists((int)laihan.I_LAIHANLX, isAdd ? null :laihan.S_LAIHANBH, UCLHUserInfo.YONGHUH, Convert.ToString(laihan.I_Y), Convert.ToString(laihan.I_M), out msg))
        //    {
        //        return msg+"|-1" ;
        //    }
        //    laihan.I_AUTOTYPE = 0;
        //    laihan.D_CAOZUOSJ = DateTime.Now;
        //    laihan.S_CAOZUOR = LoginInfo.CurrentUser.Account;
        //    string laihanbh = "";
        //    string xukebh = "";
        //    string zd, glk;
        //    if (BusinessTool.WType != 0)
        //    {
        //        zd = null;
        //        glk = BusinessTool.QSGLKH;
        //    }
        //    else
        //    {
        //        DataTable dt = BusinessTool.GetTextAndValue("YS_YG_YONGHUXX", "S_ZHANDIANBH", "S_GUANLIKBH", null, "I_JLZT=0 AND I_LEIXING=1 AND S_YONGHUH='" + UCLHUserInfo.YONGHUH + "'").Tables[0];
        //        zd = dt.Rows[0]["TEXT"].ToString();
        //        glk = dt.Rows[0]["VALUE"].ToString();
        //    }
        //    if (isAdd)
        //    {
        //        DataSet numset = _sphelper.P_YS_LH_XUKEBH(glk, 1, 0, UCLHUserInfo.Y, out xukebh, out laihanbh);

        //        h_laihan.Value = laihanbh;
        //    }
        //    else
        //    {
        //        laihanbh = h_laihan.Value;
        //        xukebh = UCLHUserInfo.XUKEBH;

        //    }
        //    laihan.S_LAIHANBH = laihanbh; 
        //    laihan.S_BEIYONG1 = xukebh;
        //    laihan.S_XUKEBH = xukebh;
        //    laihan.I_LIUCHENGZT = (int)eLaiHanLCZT.流程中;
           
        //    if (!CheckCAILIAO(laihan.S_LAIHANBH))
        //    {

        //        return "月度用水计划指标的调整申请表未上传|-7";
        //    }
        //    laihan.S_TONGYIBM = UCLHUserInfo.TONGYIBM;//统一审批编码
        //    laihan.S_YONGHUBH = UCLHUserInfo.YONGHUH;
        //    laihan.S_YONGHUM = this.UCLHUserInfo.YONGHUM;
        //   // DataTable dt=BusinessTool.GetTextAndValue("YS_YG_YONGHUXX", "S_YONGHUH", "S_ZHANDIANBH", null, "I_LEIXING=1 AND S_YONGHUH='" + laihan.S_YONGHUBH + "'").Tables[0];
        //    laihan.S_ZHANDIANBH = zd;
        //    laihan.S_GUANLIKBH = glk;
        //    if (laihan.ID == 0||liuchengzt==1)
        //    {
        //        bllh.InsertOrUpdate(laihan);
        //    }


        //    //添加来函附表（月调整）信息
        //    YS_LH_YUETIAOZ yuetz = new YS_LH_YUETIAOZ();
        //    yuetz.ID = 0;
        //    DataTable yuetiaoz = bllyue.SelectYS_LH_YUETIAOZsDynamic(string.Format(" S_LAIHANBH='{0}' and S_YONGHUBH='{1}'", laihan.S_LAIHANBH, laihan.S_YONGHUBH), "", null);
        //    if (yuetiaoz != null && yuetiaoz.Rows.Count > 0)
        //    {
        //        yuetz.ID = Convert.ToInt32(yuetiaoz.Rows[0]["ID"]);
        //    }
        //    yuetz.D_SHURURQ = DateTime.Now;
        //    yuetz.I_JLZT = 0;
        //    yuetz.I_M = Convert.ToInt32(UCLHUserInfo.M);
        //    yuetz.I_Y = Convert.ToInt32(UCLHUserInfo.Y);

        //    yuetz.S_LAIHANBH = laihan.S_LAIHANBH;
        //    yuetz.S_YONGHUBH = laihan.S_YONGHUBH;
        //    yuetz.S_ZHANDIANBH = laihan.S_ZHANDIANBH;
        //    int sqjhl = Convert.ToInt32(txtJHL.Text);
        //    if (chkBAI.Checked)
        //    {
        //        //sqjhl = sqjhl * 100;
        //    }
        //    yuetz.I_SHENQINGL = sqjhl;
        //    yuetz.I_SHURUR = LoginInfo.CurrentUser.UserID;
          
        //    ///有计划信息才会插入调整信息
            
        //    bllyue.InsertOrUpdate(yuetz);
           
        //    ///如果有新上传的文件信息插入数据库

        //    UCLHCaiLiaoInfo.SHOUJIAN(laihan);


        //    ///审核通过后更新用户信息 现在记录在来函用户信息表中
        //    YS_LH_YONGHUXX lhyhxx = new YS_LH_YONGHUXX();

        //    lhyhxx.ID = 0;
        //    lhyhxx.D_XIUGAIRQ = DateTime.Now;
        //    lhyhxx.S_DIZHI = UCLHUserInfo.DIZHI;
        //    lhyhxx.S_LAIHANBH = laihan.S_LAIHANBH;
        //    lhyhxx.S_LIANXIBM = UCLHUserInfo.LIANXIBM;

        //    lhyhxx.S_LIANXIDH = UCLHUserInfo.LIANXIDH+" "+UCLHUserInfo.LIANXISJ;
        //    lhyhxx.S_LIANXIR = UCLHUserInfo.LIANXIR;
        //    lhyhxx.S_YONGHUBH = laihan.S_YONGHUBH;
        //    lhyhxx.S_YONGHUM = UCLHUserInfo.YONGHUM;
        //    lhyhxx.S_YOUBIAN = UCLHUserInfo.YOUBIAN;
        //    DataTable oldyh = laihanyhxx.SelectYS_LH_YONGHUXXesDynamic(string.Format(" I_JLZT=0 and S_LAIHANBH='{0}'",laihan.S_LAIHANBH), "", null);
        //    if (oldyh != null && oldyh.Rows.Count > 0)
        //    {
        //        lhyhxx.ID = Convert.ToInt32(oldyh.Rows[0]["ID"]);
        //    }
        //    laihanyhxx.InsertOrUpdate(lhyhxx);

        //   ///添加流程记录信息
        //    YS_LH_LAIHANLCJL lcjl = new YS_LH_LAIHANLCJL();
        //    lcjl.D_CAOZUORQ = DateTime.Now;
        //    lcjl.D_STARTDATE = DateTime.Now;
        //    lcjl.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
        //    lcjl.I_LAIHANLX = 1;
        //    lcjl.I_LIUCHENGBH = liuchengzt;
        //    lcjl.ID = 0;

        //    DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ",laihan.S_LAIHANBH,liuchengzt), "", null);
        //    if (lcxx != null && lcxx.Rows.Count > 0)
        //    {
        //        lcjl.ID = Convert.ToInt32(lcxx.Rows[0]["ID"]);
        //    }
        //    lcjl.S_LAIHANBH = laihan.S_LAIHANBH;

        //    lcjl.S_LIUCHENGMC = liuchengzt==1?"登记":"预登记";
        //    if (lcjl.ID == 0)
        //    {
        //        lcbll.InsertOrUpdate(lcjl);
        //    }
        //    UpdateLiuCheng(laihan.S_LAIHANBH,liuchengzt);

        //    _SYS_LOGBLL.Log<YS_LH_LAIHANXX>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "月调整流程-月调整登记", OperateState.Modify, laihan, null);

        //    _SYS_LOGBLL.Log<YS_LH_YUETIAOZ>(LoginInfo.CurrentUser, BusinessTool.WType.ToString(), "月调整流程-月调整登记", OperateState.Modify, yuetz, null);
        //    Session["gaopai"] = null;

        //    LaiHanID = laihan.ID.ToString();
        //    LaiHanLCBH = laihan.I_LIUCHENGBH.ToString();

        //    return "操作成功|1|"+LaiHanID;
        //}
        private void UpdateLiuCheng(string laihanbh,int LiuChengBH)
        {
            DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ", laihanbh, LiuChengBH), " ID desc ", null);
            
            if (lcxx != null && lcxx.Rows.Count > 0&&LiuChengBH>0)
            {
              
                lcbll.UpdateYS_LH_LAIHANLCJLsDynamic(string.Format("D_ENDDATE=sysdate,I_CAOZUOR={0},D_CAOZUORQ=sysdate", LoginInfo.CurrentUser.UserID), " I_LIUCHENGBH=0 and S_LAIHANBH='" + laihanbh + "'");
               
            }

        }      

        /// <summary>
        /// 绑定原计划和实用水量
        /// </summary>
        private string BindYJH()
        {
            //int y, m;
            //string yd = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            //int year = Convert.ToInt32(yd.Substring(0, 4));
            //int month = int.Parse(yd.Substring(4, 2));
            //if (!int.TryParse(UCLHUserInfo.Y, out y) || !int.TryParse(UCLHUserInfo.M, out m) || m > 12 || m < 1)
            //{
                
            //    return "年月输入错误|-2";
            //}
            //if (y * 100 + m < year * 100 + month)
            //{
               
            //    return "年月必须大于/等于当前水量年月|-2";
            //}
            //if (m == 1)
            //{
            //    y = y - 1;
            //    m = 12;
            //}
            //else
            //{
            //    m = m - 1;
            //}
            //if (UCLHUserInfo.YONGHUH.Trim().Length == 0)
            //{                
            //    return "用户号格式错误|-8";
            //}
            //DataSet ds = _sphelper.P_YS_LH_YONGHUYSSJCX(y, m, UCLHUserInfo.YONGHUH.Trim(),null);
            //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            //{
            //    try
            //    {
            //        //string indexs = BindCheckBox();
            //        int YJH = Convert.ToInt32(ds.Tables[0].Rows[0]["I_YUANJIHUA"]);
            //        int SYL = Convert.ToInt32(ds.Tables[0].Rows[0]["I_SHIYONGSL"]);
            //        txtYJH.Text = (YJH).ToString();
            //        txtSYL.Text = (SYL).ToString();
            //        chkBAI.Checked = true;
            //        //return "绑定计划|2|" + YJH + "|" + SYL + "|" + indexs;
            //        return "绑定计划|2|" + YJH + "|" + SYL;
            //    }
            //    catch(Exception ex)
            //    {
            //        PageTools.AlertMsg(this, ex.Message);
            //        return ex.Message+"|-10";
            //    }
                

            //}
            //else
            //{
                
            //    return "查询不到该用户计划信息|-9";
            //}
            return null;
        }


        private string BindCheckBox()
        {
            string where = "";
            string indexs = "";
            if (UCLHUserInfo.YONGHUH.Trim().Length==0)
            {
                return "";
            }
            else
            {
                where = string.Format(" (S_YONGHUBH='{0}' and I_WENJIANLX<>2) and i_jlzt=0 ", UCLHUserInfo.YONGHUH);
            }
            if (h_laihan.Value.Trim().Length > 0)
            {
                where = string.Format(" (S_YONGHUBH='{1}' and (S_LAIHANBH='{0}' or I_WENJIANLX<>2)) and i_jlzt=0 ", h_laihan.Value, UCLHUserInfo.YONGHUH);
            }
            DataTable dt = bllupload.SelectSYS_UPLOADsDynamic(where, "", null);
            if (dt != null && dt.Rows.Count > 0)
            {
                
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (DevExpress.Web.ListEditItem li in UCLHCaiLiaoInfo.CaiLiaoCheckBoxList.Items)
                    {
                        if (li.Value.ToString() == dr["I_WENJIANLX"].ToString())
                        {
                            indexs += li.Index+",";
                        }
                    }
                }
                if (indexs.Length > 0)
                {
                    indexs = indexs.Remove(indexs.LastIndexOf(','));
                }
            }
            return indexs;
        }

        /// <summary>
        /// 初始化页面绑定值
        /// </summary>
        private void InitControl()
        {           
            //int y, m;
            //string yd = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            //int year = Convert.ToInt32(yd.Substring(0, 4));
            //int month = int.Parse(yd.Substring(4, 2));

            //DataSet ds = _sphelper.P_YS_LH_LAIHANZLLB(1);
            //DataTable dt=ds.Tables[0];
            //if (ds != null && ds.Tables.Count > 0)
            //{
               
            //    Session["LBID"] = ds.Tables[0].Rows[0]["I_CAILIAOBH"];
            //    Session["LB"] = ds.Tables[0].Rows[0]["S_CAILIAOMC"];
            //}           

            //Session["gaopai"] = null;
            
        }        

        /// <summary>
        /// 清空控件值
        /// </summary>
        protected void ClearControlValue()
        { 
            //清空session
            Session["gaopai"] = null;
            Session["LB"] = null;
            Session["LBID"] = null;
        }

        private void BindEditData()
        {
            YS_LH_LAIHANXX laihanxx = null;
            //加载申请信息
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                laihanxx = new YS_LH_LAIHANXXProcess().SelectYS_LH_LAIHANXX(decimal.Parse(Request["id"]));
            }
            else
            {
                laihanxx = new YS_LH_LAIHANXX();
            }
            if (!string.IsNullOrEmpty(Request["yonghuh"]))
            {
                laihanxx.S_YONGHUBH = Request["yonghuh"];
            }
            this.UCLHBtnBottom.LoadInfo(laihanxx);
            this.UCLHCaiLiaoInfo.LoadInfo(laihanxx);
            this.UCLHSJBTNS.LoadInfo(laihanxx);
            string yd = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            int year = Convert.ToInt32(yd.Substring(0, 4));
            int month = int.Parse(yd.Substring(4, 2));
            UCLHUserInfo.Y = year.ToString();
            UCLHUserInfo.M = month.ToString();
            if (!string.IsNullOrEmpty(Request["yonghuh"]))
            {                
                UCLHUserInfo.KuaiJieDJ(Request["yonghuh"]);
                laihanxx.I_TZY = year;
                laihanxx.I_TZM = month;                
                this.UCLHShenQingXX_YDTZ.LoadInfo(laihanxx);
            }
            else
            {
                this.UCLHUserInfo.LoadInfo(laihanxx);
                this.UCLHShenQingXX_YDTZ.LoadInfo(laihanxx);
            }
            
            //int id = 0;
            //if (int.TryParse(Request["id"], out id))
            //{
            //    if (id != -1)
            //    {
            //        LaiHanID = id.ToString();
            //    }
            //}

            //if (LaiHanID == "0" || LaiHanID == "")
            //{
            //    UCLHUserInfo.LoadInfo(new YS_LH_LAIHANXX());
            //    UCLHSJBTNS.LoadInfo(new YS_LH_LAIHANXX());
            //    return;
            //}
            //YS_LH_LAIHANXX lh = bllh.SelectYS_LH_LAIHANXX(int.Parse(LaiHanID));
            //if (lh == null)
            //{
            //    return;
            //}
            //UCLHUserInfo.LoadInfo(lh);
            //UCLHSJBTNS.LoadInfo(lh);
            //LaiHanID = lh.ID.ToString();
            //LaiHanLCBH = lh.I_LIUCHENGBH.ToString();

            //h_laihan.Value = lh.S_LAIHANBH;
            //h_yonghu.Value = lh.S_YONGHUBH;

            //UCLHBtnBottom.LoadInfo(lh);

            //UCLHCaiLiaoInfo.BindCheckBox(lh.S_YONGHUBH, lh.S_LAIHANBH);

            //SetDisplay(lh);
           
        }
        /// <summary>
        /// 设置登记还是受理状态
        /// </summary>
        /// <param name="laihanxx"></param>
        private void SetDisplay(YS_LH_LAIHANXX laihanxx)
        {
            //if (laihanxx.I_LIUCHENGBH == 0)
            //{
            //    DengJi.Visible = true;
            //    ShouLi.Visible = false;
            //}
            //if (laihanxx.I_LIUCHENGBH == 1)
            //{
            //    DengJi.Visible = false;
            //    ShouLi.Visible = true;
            //    txtJHL.ReadOnly = true;
            //    chkBAI.ReadOnly = true;
            //}
        }
       
        #endregion
        /// <summary>
        /// 重新加载数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void BtnReload_Click(object sender, EventArgs e)
        //{
        //    BindEditData();
        //}

    }
}